<?php
session_start();
include '../model/db.php'; //引入数据库操作文件
include '../model/fn.php';//引入公共方法
$sql="select * from bl_user limit 1";
$wzarr=db_sel($sql); //网站设置的所有信息

$csql="select * from bl_class where pid=0";//查询所有的一级分类
$classarr=db_sel($csql,2); //得到所有的一级分类

///***自动登录****/
if(!empty($_COOKIE['home_user'])){
    //查询用户名，保存到session，实现自动登录
    $sql="select * from bl_member where user='{$_COOKIE['home_user']}'";
    $member=db_sel($sql);
    if(!empty($member)){
        //生成session
        $_SESSION['home']['id']=$member['id'];
        $_SESSION['home']['user']=$member['user'];
        $_SESSION['home']['nickname']=$member['nickname'];
    }
}
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $wzarr['w_title']?></title>
    <meta name="keywords" content="个人博客模板,博客模板" />
    <meta name="description" content="寻梦主题的个人博客模板，优雅、稳重、大气,低调。" />
    <link href="../public/home/css/base.css" rel="stylesheet">
    <link href="../public/home/css/index.css" rel="stylesheet">
    <script src="../public/home/js/jquery.js"></script>
    <!--[if lt IE 9]>
    <script src="../public/home/js/modernizr.js"></script>
    <![endif]-->
    <style>
        /*//banner 修改*/
        .banner {
            background: url(<?php echo $wzarr['w_banner']?>) top center;
        }

        /*头像 修改*/
        .avatar a{
            background: url(<?php echo $wzarr['tx']?>) no-repeat;
        }
        #logo a{
            background: url(<?php echo $wzarr['w_logo']?>) no-repeat;
        }
    </style>
</head>
<body>
<header>
    <div id="logo"><a href="/"></a></div>
    <nav class="topnav" id="topnav">
        <a href="index.php"><span>首页</span><span class="en">Protal</span></a>
        <!--        显示所有文章顶级分类-->
        <?php foreach($classarr as $v){?>
            <a href="./newlist.php?cid=<?php echo $v['id']?>"><span><?php echo $v['name']?></span><span class="en">Learn</span></a>
        <?php }?>
        <a href="book.html"><span>留言版</span><span class="en">Gustbook</span></a>
        <!--        如果登录就显示用户名-->
        <?php if($_SESSION['home']['id']){?>
            <a href="./exc.php?type=tc">
                <span>欢迎：<?php echo $_SESSION['home']['user']?></span>
                <span class="en">Gustbook</span>
            </a>
        <?php }?>
    </nav>
</header>







